package com.house.system.controller;

import com.house.common.utils.PageUtils;
import com.house.common.utils.R;

import com.house.system.entity.TbSubwayLine;
import com.house.system.service.SubwayService;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/subway")
public class SubwayController {
    private  final SubwayService subwayService;

    public SubwayController(SubwayService subwayService) {
        this.subwayService = subwayService;
    }


    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = subwayService.queryPage(params);
        return R.ok().put("page", page);
    }

    @RequestMapping("/findlist/{aid}")
    public R findlist(@PathVariable("aid") Integer cid){
        List<TbSubwayLine> tbSubwayLineList = subwayService.findlist(cid);
        return  R.ok().put("tbsubway",tbSubwayLineList);
    }


    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody TbSubwayLine tbSubwayLine){
        subwayService.saves(tbSubwayLine);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody TbSubwayLine tbSubwayLine){
        subwayService.updateByIds(tbSubwayLine);


        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete/{id}")
    public R delete(@PathVariable("id") Integer id){
        subwayService.removeByIds(id);

        return R.ok();
    }

}
